#include "trap.h"
   .set noat                # 禁止使用保留寄存器$at
   .globl main
   .text

main:
   # 初始化寄存器
   lui     $t0, 0x1010          # $t0 = 0x10100000
   nop                          # 保持流水线延迟
   ori     $t0, $t0, 0x1010     # $t0 = 0x10101010

   ori     $t1, $zero, 0x0008   # $t1 = 0x00000008

   lui     $t2, 0xFFFF          # $t2 = 0xFFFF0000
   ori     $t2, $t2, 0xFFFF     # $t2 = 0xFFFFFFFF

   lui     $t3, 0xFFFF          # $t3 = 0xFFFF0000
   ori     $t3, $t0, 0xFFFE     # $t3 = 0x1010FFFE

   lui     $v0, 0x1234          # $v0 = 0x12340000
   ori     $v0, $t0, 0x5678     # $v0 = 0x10105678

   ori     $v1, $t0, 0x0020     # $v1 = 0x10100020

   # 加法操作
   add     $t4, $t0, $t1        # $t4 = $t0 + $t1
   add     $t5, $t0, $t2        # $t5 = $t0 + $t2
   addu    $t6, $t0, $t1        # $t6 = $t0 + $t1 (无符号)
   addu    $t7, $t1, $t2        # $t7 = $t1 + $t2 (无符号)

   # 减法操作
   sub     $t4, $t0, $t1        # $t4 = $t0 - $t1
   sub     $t5, $t3, $t1        # $t5 = $t3 - $t1
   sub     $t6, $t1, $t2        # $t6 = $t1 - $t2
   subu    $t7, $t0, $t1        # $t7 = $t0 - $t1 (无符号)

   # 比较操作
   slt     $t4, $t1, $t0        # $t4 = ($t1 < $t0) ? 1 : 0
   slt     $t5, $t1, $t2        # $t5 = ($t1 < $t2) ? 1 : 0
   sltu    $t6, $t1, $t0        # $t6 = ($t1 < $t0 无符号) ? 1 : 0
   sltu    $t7, $t1, $t2        # $t7 = ($t1 < $t2 无符号) ? 1 : 0

   # 逻辑操作
   and     $t4, $t1, $t2        # $t4 = $t1 & $t2
   nor     $t5, $t0, $v0        # $t5 = ~($t0 | $v0)
   or      $t6, $t1, $t0        # $t6 = $t1 | $t0
   xor     $t7, $t3, $v0        # $t7 = $t3 ^ $v0

   # 移位操作
   sllv    $t4, $t3, $t1        # $t4 = $t3 << $t1
   sllv    $t5, $t3, $v1        # $t5 = $t3 << $v1
   srav    $t6, $t3, $t1        # $t6 = $t3 >> $t1 (算术右移)
   srlv    $t7, $t3, $t1        # $t7 = $t3 >> $t1 (逻辑右移)

   # 程序结束
   HIT_GOOD_TRAP                # 停止模拟器